package com.fesnakj.todoer.data;

import com.fesnakj.todoer.model.TaskImpl;
import com.fesnakj.todoer.model.TaskState;

import java.util.ArrayList;
import java.util.List;

public class TaskPool {

    static TaskPool instance = null;
    private List<TaskImpl> tasks;

    private TaskPool() {
        this.tasks = generateTasks();
    }

    private TaskPool(List<TaskImpl> tasks) {
        this.tasks = tasks;
    }

    public static List<TaskImpl> getTasks() {
        if (instance == null)
            instance = new TaskPool();
        return instance.getTaskList();
    }

    private List<TaskImpl> getTaskList() {
        return tasks;
    }

    private List<TaskImpl> generateTasks() {
        List<TaskImpl> tasks = new ArrayList<TaskImpl>();
        tasks.add(new TaskImpl(1, "Buy a milk"));
        tasks.add(new TaskImpl(2, "Call Emma", TaskState.ONGOING));
        tasks.add(new TaskImpl(3, "Fix the window"));
        tasks.add(new TaskImpl(4, "Prepare dinner", TaskState.COMPLETED));
        tasks.add(new TaskImpl(5, "Buy a milk", TaskState.COMPLETED));
        TaskImpl task = new TaskImpl(6, "Some described task");
        task.setDescription("This is task description");
        tasks.add(task);
        return tasks;
    }

}
